package Proxy;

import net.sf.cglib.proxy.Enhancer;

import net.sf.cglib.proxy.*;
import net.sf.cglib.proxy.Callback;
import net.sf.cglib.proxy.CallbackFilter;
//import net.sf.cglib.proxy.Enhancer;
//import net.sf.cglib.proxy.NoOp;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
public class TestCglib {
	public static void main(String args[]) {
		//创建Enhancer对象
		Enhancer enhancer = new Enhancer();
		//设置哪个类需要代理
		enhancer.setSuperclass(TargetObject.class);
		// 设置怎么代理
		enhancer.setCallback(new TargetInterceptor());
		// 获取代理类实例
		TargetObject targetObject2 = (TargetObject) enhancer.create();
		System.out.println(targetObject2);
		System.out.println(targetObject2.method1("mmm1"));
		System.out.println(targetObject2.method2(100));
		System.out.println(targetObject2.method3(200));
	}
}